all: Kitsch vm

test: tests/run_tests.py
	cd tests; python run_tests.py	

vm: src/vm.py
	cp src/vm.py bin
	chmod +x bin/vm.py

Kitsch: bin src/FuncVisitor.java src/Evaluator.java src/Compiler.java src/Kitsch.java src/pj2.jar ./builtins src/builtins tests/builtins bin/builtins
	javac -classpath src/pj2.jar src/Kitsch.java src/Evaluator.java src/Compiler.java src/TypeChecker.java src/OperatorRegistry.java src/FuncVisitor.java -d bin/
	jar xf src/pj2.jar
	cp -r META-INF bin
	cp -r pj2 bin
	rm -rf META-INF pj2
	cp src/builtins/*.k builtins
	cp src/builtins/*.k bin/builtins
	cp src/builtins/*.k tests/builtins

./builtins: 
	mkdir builtins

src/builtins:
	mkdir src/builtins

tests/builtins:
	mkdir tests/builtins

bin/builtins:
	mkdir bin/builtins

clean: bin
	rm bin/*.class
	rm bin/vm.py
	rm -rf bin/META-INF
	rm -rf bin/pj2
	find tests -name "*.ko" | xargs rm
	rm -rf builtins
	rm -rf bin/builtins
	rm -rf tests/builtins
bin:
	mkdir bin
